package lc.oa.ui.adapter;

import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.recyclerview.widget.RecyclerView;

import java.util.List;

import lc.oa.R;
import lc.oa.data.model.ToDoModel;

public class ToDoAdapter extends RecyclerView.Adapter<ViewHolder> {

    private List<ToDoModel> data;

    public ToDoAdapter(List<ToDoModel> data) {
        this.data = data;
    }

    @NonNull
    @Override
    public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        ConstraintLayout row = (ConstraintLayout) LayoutInflater.from(parent.getContext()).inflate(R.layout.row, parent, false);

        return new ViewHolder(row);
    }

    @Override
    public void onBindViewHolder(@NonNull ViewHolder holder, int position) {
        holder.getTitle().setText(data.get(position).getTitle());
        holder.getDescription().setText(data.get(position).getDesction());
    }

    @Override
    public int getItemCount() {
        return data.size();
    }
}

